Template container iterator base class (abstract). More...
#include <tcontainer.h>
Public Member Functions | |
TIterator (const TContainer< T > &cont) | |
virtual | ~TIterator () |
virtual bool | done () const =0 |
Check if end of container is reached. | |
virtual T & | next ()=0 |
Returns the current data and advances the iterator. postfix as in t = c++;. | |
virtual T & | previous ()=0 |
Returns the current data and backup. postfix as in t = c--;. | |
virtual T & | current () const =0 |
Returns the current data. | |
virtual void | first ()=0 |
Move to first data. | |
virtual void | last ()=0 |
Move to last data. | |
T & | next (const T &) |
Advance to next equal. | |
T & | previous (const T &) |
Backup to previous equal. | |
const TContainer< T > & | container () const |
Return container reference. | |
operator int32 () const | |
Check if not end. | |
T & | operator++ () |
Advance the iterator to the next item and return it. | |
T & | operator++ (int) |
Return the current item and advance the iterator to the next. | |
T & | operator+= (int32 n) |
Advance the iterator n places and returns the item. | |
T & | operator-- () |
Decrement the iterator by one and return the item. | |
T & | operator-- (int) |
Return the current item and decrement the iterator by one. | |
T & | operator-= (int32) |
Decrement the iterator n places and returns the item. | |
T & | operator() () const |
Return current item. | |
Protected Attributes | |
const TContainer< T > & | _container |
Iterated container. |
Template container iterator base class (abstract).
Each container implementation has a matching iterator. This class defines the basic interface for any iterator implementation.
Please note that TIterator::next and TIterator::previous always return the current iterator item and switch to the new item afterwards. This allows iteration loops in this style:
TLinkedList<int> myList; ... TLinkedListIterator<int> iter (myList); while (iter.done () == false) { int myInt = iter.next (); }
TIterator | ( | const TContainer< T > & | cont | ) | [inline, explicit] |
virtual ~TIterator | ( | ) | [inline, virtual] |
virtual bool done | ( | ) | const [pure virtual] |
Check if end of container is reached.
Implemented in TArrayIterator< T >, TBTreeIterator< T >, TDLinkedListIterator< T >, THashTableIterator< T >, TLinkedListIterator< T >, TDLinkedListIterator< TAssociation< TKey, TObject > >, and THashTableIterator< TAssociation< TKey, TObject > >.
virtual T& next | ( | ) | [pure virtual] |
Returns the current data and advances the iterator. postfix as in t = c++;.
Implemented in TArrayIterator< T >, TBTreeIterator< T >, TDLinkedListIterator< T >, THashTableIterator< T >, TLinkedListIterator< T >, TDLinkedListIterator< TAssociation< TKey, TObject > >, and THashTableIterator< TAssociation< TKey, TObject > >.
virtual T& previous | ( | ) | [pure virtual] |
Returns the current data and backup. postfix as in t = c--;.
Implemented in TArrayIterator< T >, TBTreeIterator< T >, TDLinkedListIterator< T >, THashTableIterator< T >, TLinkedListIterator< T >, TDLinkedListIterator< TAssociation< TKey, TObject > >, and THashTableIterator< TAssociation< TKey, TObject > >.
virtual T& current | ( | ) | const [pure virtual] |
Returns the current data.
Implemented in TArrayIterator< T >, TBTreeIterator< T >, TDLinkedListIterator< T >, THashTableIterator< T >, TLinkedListIterator< T >, TDLinkedListIterator< TAssociation< TKey, TObject > >, and THashTableIterator< TAssociation< TKey, TObject > >.
virtual void first | ( | ) | [pure virtual] |
virtual void last | ( | ) | [pure virtual] |
T & next | ( | const T & | rItem | ) | [inline] |
Advance to next equal.
T & previous | ( | const T & | rItem | ) | [inline] |
Backup to previous equal.
const TContainer< T > & container | ( | ) | const [inline] |
Return container reference.
operator int32 | ( | ) | const [inline] |
Check if not end.
T & operator++ | ( | ) | [inline] |
Advance the iterator to the next item and return it.
T & operator++ | ( | int | ) | [inline] |
Return the current item and advance the iterator to the next.
T & operator+= | ( | int32 | n | ) | [inline] |
Advance the iterator n places and returns the item.
T & operator-- | ( | ) | [inline] |
Decrement the iterator by one and return the item.
T & operator-- | ( | int | ) | [inline] |
Return the current item and decrement the iterator by one.
T & operator-= | ( | int32 | num | ) | [inline] |
Decrement the iterator n places and returns the item.
T & operator() | ( | ) | const [inline] |
Return current item.
const TContainer<T>& _container [protected] |
Iterated container.